define(function(require, exports, module) {

	$.fn.extend({

		loading:function(op) {
			var me = this;
			$(this).removeClass("box");
			$(this).children(".loading").remove();
			if(op != "close") {
				var icon = op ? op : 1;
				var _this = $(this);
				_this.addClass("box");
				var loading = $('<div class="loading"><div class="layui-layer-loading" align="center"><div class="layui-layer-loading' + icon + '"></div></div></div>').appendTo(this);
				var icon = loading.find(".layui-layer-loading");
				icon.css({
					"margin-left": - icon.outerWidth() / 2,
					"margin-top": - icon.outerHeight() / 2
				});
				return {
					close:function() {
						$(me).loading("close");
					}
				}
			}
		}

	});
	module.exports = {

		loading: function(selector, op) {
			$(selector).loading(op);
		}
		
	}
});